using UnityEngine;

namespace Crosstales.OnlineCheck.Util
{
    // [Assembly-CSharp-firstpass.dll].Crosstales.OnlineCheck.Util.NetworkInfo
    public static class NetworkInfo
    {
        
        #region Crosstales.OnlineCheck.Util.NetworkInfo.<>c
        // [Assembly-CSharp-firstpass.dll].Crosstales.OnlineCheck.Util.NetworkInfo.<>c
        [Serializable]
        private sealed class __c
        {
            // Fields
            public static readonly Crosstales.OnlineCheck.Util.NetworkInfo.<>c __9;
            public static System.Func<System.Net.NetworkInformation.NetworkInterface, bool> __9__9_0;
            public static System.Func<byte, string> __9__9_1;
            public static System.Func<System.Net.NetworkInformation.UnicastIPAddressInformation, bool> __9__9_2;
            public static System.Func<System.Net.NetworkInformation.GatewayIPAddressInformation, System.Net.IPAddress> __9__9_3;
            public static System.Func<System.Net.IPAddress, bool> __9__9_4;
            
            // Methods
            private static __c()
            {
                object val_1 = 536899475;
                val_1 = new System.Object();
                mem2[0] = val_1;
                throw new NullReferenceException();
            }
            public __c()
            {
            
            }
            internal bool <getNetworkInterfaces>b__9_0(System.Net.NetworkInformation.NetworkInterface ni)
            {
                return (bool)(ni == 1) ? 1 : 0;
            }
            internal string <getNetworkInterfaces>b__9_1(byte val)
            {
                string val_3 = val.ToString(format:  -1610601315);
                if(val_1._stringLength != 1)
                {
                        return (string)val_3;
                }
                
                val_3 = -1610611407(-1610611407) + val_3;
                return (string)val_3;
            }
            internal bool <getNetworkInterfaces>b__9_2(System.Net.NetworkInformation.UnicastIPAddressInformation ua)
            {
                if(ua == null)
                {
                        return (bool)(ua.AddressFamily == 2) ? 1 : 0;
                }
                
                return (bool)(ua.AddressFamily == 2) ? 1 : 0;
            }
            internal System.Net.IPAddress <getNetworkInterfaces>b__9_3(System.Net.NetworkInformation.GatewayIPAddressInformation g)
            {
                goto typeof(System.Net.NetworkInformation.GatewayIPAddressInformation).__il2cppRuntimeField_178;
            }
            internal bool <getNetworkInterfaces>b__9_4(System.Net.IPAddress a)
            {
                return (bool)(a != 0) ? 1 : 0;
            }
        
        }
        
        #endregion
        
        // Fields
        private static System.Collections.Generic.List<Crosstales.OnlineCheck.Model.NetworkInterface> interfaceCache;
        private static string publicIpCache;
        
        // Properties
        public static string PublicIP { get; }
        public static System.Collections.Generic.List<Crosstales.OnlineCheck.Model.NetworkInterface> LastNetworkInterfaces { get; }
        public static string LastPublicIP { get; }
        public static bool isPlatformSupported { get; }
        
        // Methods
        public static string get_PublicIP()
        {
            object val_6;
            var val_10;
            Crosstales.Common.Util.CTWebClient val_11;
            var val_12;
            var val_13;
            var val_14;
            var val_15;
            var val_16;
            var val_17;
            var val_18;
            var val_19;
            var val_20;
            val_11 = 27353496;
            System.Net.Security.RemoteCertificateValidationCallback val_1 = 536891487;
            if(val_1 == 0)
            {
                    throw new NullReferenceException();
            }
            
            val_10 = 27343304;
            val_1 = new System.Net.Security.RemoteCertificateValidationCallback(object:  0, method:  1610683701);
            val_12 = 0;
            System.Net.ServicePointManager.ServerCertificateValidationCallback = val_1;
            val_11 = 536883417;
            if(536883417 == 0)
            {
                    throw new NullReferenceException();
            }
            
            val_11 = new Crosstales.Common.Util.CTWebClient(timeout:  136, connectionLimit:  20);
            string val_3 = val_11.DownloadString(address:  -1610598141);
            val_13 = 536882899;
            if(mem[536883123] == 0)
            {
                    val_13 = 536882899;
            }
            
            if((mem[536883083] + 72) != 0)
            {
                    UnityEngine.Debug.LogWarning(message:  -1610608639(-1610608639) + val_3);
            }
            
            val_14 = val_3.Trim();
            val_15 = 0;
            label_19:
            var val_10 = mem[536883417];
            var val_9 = mem[536883417] + 298;
            if(val_9 == 0)
            {
                goto label_8;
            }
            
            var val_8 = mem[536883417] + 176;
            val_8 = val_8 + 8;
            label_10:
            if(((mem[536883417] + 176 + 8) + -8) == 536887297)
            {
                goto label_9;
            }
            
            val_9 = val_9 - 1;
            val_8 = val_8 + 16;
            if(((mem[536883417] + 176 + 8) + -8) != 536887297)
            {
                goto label_10;
            }
            
            label_8:
            val_16 = val_11;
            goto label_11;
            label_9:
            val_10 = val_10 + (((mem[536883417] + 176 + 8)) << 4);
            val_16 = val_10 + 312;
            label_11:
            val_12 = mem[((mem[536883417] + ((mem[536883417] + 176 + 8)) << 4) + 312) + 8];
            val_12 = ((mem[536883417] + ((mem[536883417] + 176 + 8)) << 4) + 312) + 8;
            if(val_15 != 0)
            {
                goto label_17;
            }
            
            if(3 != 0)
            {
                    return (string)val_14;
            }
            
            val_17 = 0;
            label_29:
            UnityEngine.Debug.LogWarning(message:  System.String.Format(format:  27495088, arg0:  val_6));
            val_14 = -1610595381;
            return (string)val_14;
            label_17:
            val_18 = X1;
            val_19 = 28164096;
            if(val_18 != 1)
            {
                goto label_18;
            }
            
            goto label_19;
            label_18:
            label_25:
            var val_12 = mem[536891785];
            if(val_12 == 0)
            {
                goto label_20;
            }
            
            var val_11 = mem[536891663];
            val_11 = val_11 + 8;
            label_22:
            if(((mem[536891663] + 8) + -8) == X23)
            {
                goto label_21;
            }
            
            val_12 = val_12 - 1;
            val_11 = val_11 + 16;
            if(((mem[536891663] + 8) + -8) != X23)
            {
                goto label_22;
            }
            
            label_20:
            val_20 = val_11;
            goto label_23;
            label_21:
            val_11 = val_11 + (((mem[536891663] + 8)) << 4);
            val_20 = val_11 + 312;
            label_23:
            if(0 == 0)
            {
                goto label_24;
            }
            
            goto label_25;
            label_24:
            if( != 1)
            {
                goto label_27;
            }
            
            if((27346264 & 1) == 0)
            {
                goto label_28;
            }
            
            val_6 = 1179403647;
            goto label_29;
            label_28:
            mem[8] = 1179403647;
            val_19 = 8;
            label_27:
        }
        public static System.Collections.Generic.List<Crosstales.OnlineCheck.Model.NetworkInterface> get_LastNetworkInterfaces()
        {
            var val_2 = mem[mem[536890201]];
            val_2 = mem[536890201];
            if(val_2 != 0)
            {
                    return (System.Collections.Generic.List<Crosstales.OnlineCheck.Model.NetworkInterface>)val_2;
            }
            
            System.Collections.Generic.List<Crosstales.OnlineCheck.Model.NetworkInterface> val_1 = Crosstales.OnlineCheck.Util.NetworkInfo.getNetworkInterfaces(activeOnly:  true);
            val_2 = mem[mem[536890201]];
            val_2 = mem[536890201];
            return (System.Collections.Generic.List<Crosstales.OnlineCheck.Model.NetworkInterface>)val_2;
        }
        public static string get_LastPublicIP()
        {
            var val_2 = mem[mem[536890201] + 8];
            val_2 = mem[536890201] + 8;
            if(val_2 != 0)
            {
                    return (string)val_2;
            }
            
            string val_1 = Crosstales.OnlineCheck.Util.NetworkInfo.PublicIP;
            val_2 = val_1;
            mem2[0] = val_1;
            return (string)val_2;
        }
        public static void Refresh()
        {
            mem2[0] = 0;
            mem2[0] = 0;
        }
        public static System.Collections.Generic.List<Crosstales.OnlineCheck.Model.NetworkInterface> getNetworkInterfaces(bool activeOnly = True)
        {
            var val_20;
            System.Func<Unknown, System.Boolean> val_21;
            var val_22;
            var val_23;
            var val_24;
            System.Collections.Generic.IEnumerable<Unknown> val_25;
            var val_26;
            var val_27;
            var val_28;
            System.Func<Unknown, Unknown> val_29;
            var val_30;
            System.Func<Unknown, System.Boolean> val_31;
            System.Net.IPAddress val_32;
            var val_33;
            System.Func<Unknown, Unknown> val_34;
            var val_35;
            System.Func<Unknown, System.Boolean> val_36;
            val_21 = activeOnly;
            System.Collections.Generic.List<System.Object> val_1 = 536877393;
            val_22 = val_1;
            val_23 = -1073676771;
            val_24 = 27363112;
            val_1 = new System.Collections.Generic.List<System.Object>();
            val_25 = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
            if(val_21 != false)
            {
                    val_26 = 536899475;
                if(mem[536899699] == 0)
            {
                    val_26 = 536899475;
            }
            
                val_21 = mem[mem[536899659] + 8];
                val_21 = mem[536899659] + 8;
                if(val_21 == 0)
            {
                    if(mem[536899699] == 0)
            {
                    val_26 = 536899475;
            }
            
                System.Func<System.Object, System.Boolean> val_3 = 536903171;
                val_21 = val_3;
                val_3 = new System.Func<System.Object, System.Boolean>(object:  mem[536899659], method:  1610683117);
                mem2[0] = val_21;
            }
            
                val_20 = 27440664;
                val_23 = -1073674307;
                val_25 = System.Linq.Enumerable.ToArray<System.Object>(source:  System.Linq.Enumerable.Where<System.Object>(source:  val_25, predicate:  val_21));
            }
            
            if(val_5.Length < 1)
            {
                goto label_8;
            }
            
            val_27 = 0;
            label_34:
            if(val_27 >= val_5.Length)
            {
                goto label_9;
            }
            
            val_21 = val_25[val_27];
            val_28 = 536899475;
            if(mem[536899699] == 0)
            {
                    val_28 = 536899475;
            }
            
            val_29 = mem[mem[536899659] + 16];
            val_29 = mem[536899659] + 16;
            if(val_29 == 0)
            {
                    if(mem[536899699] == 0)
            {
                    val_28 = 536899475;
            }
            
                System.Func<System.Byte, System.Object> val_7 = 536903113;
                val_29 = val_7;
                val_7 = new System.Func<System.Byte, System.Object>(object:  mem[536899659], method:  1610683119);
                mem2[0] = val_29;
            }
            
            val_30 = 536899475;
            if(mem[536899699] == 0)
            {
                    val_30 = 536899475;
            }
            
            val_31 = mem[mem[536899659] + 24];
            val_31 = mem[536899659] + 24;
            if(val_31 == 0)
            {
                    if(mem[536899699] == 0)
            {
                    val_30 = 536899475;
            }
            
                System.Func<System.Object, System.Boolean> val_11 = 536903219;
                val_31 = val_11;
                val_11 = new System.Func<System.Object, System.Boolean>(object:  mem[536899659], method:  1610683121);
                mem2[0] = val_31;
            }
            
            val_32 = System.Linq.Enumerable.FirstOrDefault<System.Object>(source:  val_21, predicate:  val_31);
            val_33 = 536899475;
            if(mem[536899699] == 0)
            {
                    val_33 = 536899475;
            }
            
            val_34 = mem[mem[536899659] + 32];
            val_34 = mem[536899659] + 32;
            if(val_34 == 0)
            {
                    if(mem[536899699] == 0)
            {
                    val_33 = 536899475;
            }
            
                System.Func<System.Object, System.Object> val_13 = 536903139;
                val_34 = val_13;
                val_13 = new System.Func<System.Object, System.Object>(object:  mem[536899659], method:  1610683123);
                mem2[0] = val_34;
            }
            
            val_35 = 536899475;
            if(mem[536899699] == 0)
            {
                    val_35 = 536899475;
            }
            
            val_36 = mem[mem[536899659] + 40];
            val_36 = mem[536899659] + 40;
            if(val_36 == 0)
            {
                    if(mem[536899699] == 0)
            {
                    val_35 = 536899475;
            }
            
                System.Func<System.Object, System.Boolean> val_15 = 536903149;
                val_36 = val_15;
                val_15 = new System.Func<System.Object, System.Boolean>(object:  mem[536899659], method:  1610683125);
                mem2[0] = val_36;
            }
            
            if(val_32 != 0)
            {
                    val_36 = val_21;
                val_32 = val_32;
                Crosstales.OnlineCheck.Model.NetworkInterface val_17 = 536890021;
                val_21 = val_17;
                val_17 = new Crosstales.OnlineCheck.Model.NetworkInterface(id:  val_36, name:  val_21, type:  val_21, address:  val_32, mask:  val_32, macAddress:  System.String.Join(separator:  -1610610375, value:  System.Linq.Enumerable.ToArray<System.Object>(source:  System.Linq.Enumerable.Select<System.Byte, System.Object>(source:  val_21.GetAddressBytes(), selector:  val_29))), gateway:  System.Linq.Enumerable.FirstOrDefault<System.Object>(source:  System.Linq.Enumerable.Select<System.Object, System.Object>(source:  val_21, selector:  val_34), predicate:  val_36), speed:  val_21, status:  val_21);
                var val_20 = mem[536877421];
                val_20 = val_20 + 1;
                mem[536877421] = val_20;
                val_24 = 27363112;
                val_25 = val_25;
                val_22 = val_22;
                if(mem[536877417] < (mem[536877409] + 24))
            {
                    var val_19 = mem[536877409] + ((mem[536877417]) << 3);
                mem[536877417] = mem[536877417] + 1;
                mem2[0] = val_21;
            }
            
                val_27 = val_27;
            }
            
            val_20 = val_27 + 1;
            if(val_20 < (val_5 + 24))
            {
                goto label_34;
            }
            
            label_8:
            mem2[0] = val_22;
            return (System.Collections.Generic.List<Crosstales.OnlineCheck.Model.NetworkInterface>)val_22;
            label_9:
        }
        public static bool get_isPlatformSupported()
        {
            bool val_1 = Crosstales.Common.Util.BaseHelper.isWebPlatform;
            bool val_2 = Crosstales.Common.Util.BaseHelper.isWSABasedPlatform;
            return true;
        }
    
    }

}
